struct ListNode* removeElements(struct ListNode* head, int val)
{
    if(head==NULL)
    return NULL;
    struct ListNode* p=head;
    struct ListNode* q=head->next;
    while(q!=NULL)
    {
        if(q->val==val)
        p->next=q->next;
        else
        p=q;
        q=q->next;
    }
    if(head->val==val)
    head=head->next;
    return head;
}

